<?php
/* 
 * ********* CVS HEADER ********* 
 * 
 * $RCSfile: admnotifadd.php,v $ 
 * $Date: 2005/10/21 12:58:07 $ 
 * $Revision: 1.3 $ 
 * 
 * ********* CVS HEADER ********* 
 */
if($action=="process"){
	if($argid==-1){
		$query = "INSERT INTO rportal_notification (nom,description,id_email) VALUES ('$nom','$description','$email')";
		@rportalrequete($query) or rportalerreur($query,"?op=");	
	}else{
		$query = "UPDATE rportal_notification SET nom='$nom',description='$description',id_email='$email' WHERE id='$argid'";
		@rportalrequete($query) or rportalerreur($query,"?op=");
	}	
	header("Location: ?op=admnotifliste");
	exit;
}
require_once("module/TPLN/TPLN.php"); 
$TPLN = new TPLN; 
$TPLN->Open($op_basepath."tpl/admnotifadd.html"); 
$TPLN->IncludeFile("header","environnement/$session[environnement]/header.php"); 
$TPLN->IncludeFile("footer","environnement/$session[environnement]/footer.php");

require_once(get_path_module("admin"));
$pc = new panneau_controle();
$pc->calculRubriqueParFonction('admnotifliste');
$TPLN->Parse("panneau_controle",$pc->retourneEntete());

$nom = '';
$description = '';
$eid = 0;
if($argid!=-1){
	$query = "SELECT * FROM rportal_notification WHERE id='$argid'";
	$result=rportalrequete($query) or rportalerreur($query,"?op=");
	if($notif=rportalligne($result)){
    	$nom = $notif['nom'];
		$description = $notif['description'];
		$eid = $notif['id_email'];
	}
}

$query = "SELECT id,nom FROM rportal_email_type";
$result=rportalrequete($query) or rportalerreur("ERREUR : $query","?op=");
while($row=rportalligne($result))
{
	$TPLN->Parse("email.eid",$row['id']);
	$TPLN->Parse("email.nom",$row['nom']);
	if($eid==$row['id']){
		$TPLN->Parse("email.selected","selected");	
	}else{
		$TPLN->Parse("email.selected","");
	}
	$TPLN->Loop("email");	
}

$TPLN->Parse("nom",$nom);
$TPLN->Parse("argid",$argid);
$TPLN->Parse("description",$description);
$TPLN->Write();
?>